#-----------------------------------------------------------------------#
#------------------CLASS Timer------------------------------------------#
#-----------------------------------------------------------------------#
from threading import Thread
import time

class Timer(Thread):        
    def __init__(self, aTimeQuantum, aKernel):
        Thread.__init__(self)
        self.quantum = aTimeQuantum
        self.kernel = aKernel
        
    def run(self):
        while(True):
            time.sleep(self.quantum)
            self.kernel.interrupt_quantumFinished()
            
#-----------------------------------------------------------------------#
#------------------CLASS ShortestJobVerifier----------------------------#
#-----------------------------------------------------------------------#        
        
class ShortestJobVerifier(Thread):
    def __init__(self, aTimeQuantum, aKernel):
        Thread.__init__(self)
        self.needsToCheckShortestJob = False
        self.kernel = aKernel
        
    def run(self):
        while(True):
            time.sleep(300)
            if(self.needsToCheckShortestJob):
                self.handleJobVerification()
            
    def setDirtyFlag(self):
        self.needsToCheckShortestJob = True
    
    def handleJobVerification(self):
        self.kernel.interrupt_processArrivedToRPQ()
        self.needsToCheckShortestJob = False
        
            
        